-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export targets #403
export targets #403
Conversation
This is currently work in progress. I am facing the following CMake error which I have to figure out what's happening:
I honestly have no real clue why |
The above error could be resolved by ros/pluginlib#190. With that PR, I am putting this PR out of draft mode. I think the exported targets look decent so far. There's no abosolute path in it. The absolute path for the include directories are coming from other packages as far as I can tell. set_target_properties(rosbag2_transport::rosbag2_transport PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/Users/karsten/workspace/ros2/ros2_master/install/include;/Users/karsten/workspace/ros2/ros2_master/install/opt/yaml_cpp_vendor/lib/cmake/yaml-cpp/../../../include"
INTERFACE_LINK_LIBRARIES "rcl::rcl;rclcpp::rclcpp;rcutils::rcutils;rmw::rmw;rosbag2_compression::rosbag2_compression;rosbag2_compression::rosbag2_compression_zstd;rosbag2_cpp::rosbag2_cpp;yaml-cpp"
) |
@emersonknapp @zmichaels11 Maybe you can help me out. I honestly don't really get how that rosbag2/zstd_vendor/CMakeLists.txt Line 52 in 69c5893
What is zstd in this case?
From what I can see here zstd does use already exported cmake targets and we should actually just leverage these. However, I am somewhat confused that there is no |
@piraka9011 do you have input on this design choice? |
I'm not too familiar with the compression code either - it seems like it's just declaring the preexisting library, either system installed or built via ExternalProject - as an ament target? |
84f1798
to
18f8d61
Compare
So I worked around this now by providing a |
18f8d61
to
2a1616e
Compare
@Karsten1987 |
0368bf9
to
64387bf
Compare
I would suggest to split the non-export target related changes into a separate PR to make this easier to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks pretty good. There are a few cleanups in here that could be punted out to a separate PR just to keep this one a little smaller. I have one question inline.
sqlite3_vendor/CMakeLists.txt
Outdated
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sqlite3_install/ DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
install( | ||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sqlite3_install/ | ||
DESTINATION .) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the rest of our vendor packages use ${CMAKE_INSTALL_PREFIX}
here:
- https://github.com/ros2/spdlog_vendor/blob/3cae65ab249d1ef3c9bfa203497007d8c7ef299f/CMakeLists.txt#L78
- https://github.com/ros2/yaml_cpp_vendor/blob/efe04baa5b3903fa238204f291f50f05d4fcdd18/CMakeLists.txt#L62
rosbag2/sqlite3_vendor/CMakeLists.txt
Line 36 in bfa6319
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sqlite3_install/ DESTINATION ${CMAKE_INSTALL_PREFIX}) DESTINATION ${CMAKE_INSTALL_PREFIX}/include/moodycamel - https://github.com/ros2/tinyxml_vendor/blob/b7a50bf7af9f7ae8c517dd06552533d4e5f4a726/CMakeLists.txt#L37
- https://github.com/ros2/rviz/blob/7ca470831304a1cd29ec207f2c07e62ddb8552f1/rviz_assimp_vendor/CMakeLists.txt#L51
- https://github.com/ros2/rviz/blob/7ca470831304a1cd29ec207f2c07e62ddb8552f1/rviz_ogre_vendor/CMakeLists.txt#L61
- https://github.com/ros2/poco_vendor/blob/3f23e18f8d71e979e03395d860bc3053d3162ae6/CMakeLists.txt#L87
- https://github.com/ament/uncrustify_vendor/blob/0291bc988c45846400aca50cb973bf04a4de3d56/CMakeLists.txt#L63
- https://github.com/ros/resource_retriever/blob/d6a6818edeebcc3af73b77ebf88d3116d489089e/libcurl_vendor/CMakeLists.txt#L64
That doesn't make the rest of them automatically correct, but I'm not sure why this one is different. Do we need to update all of those to use .
, or can we just leave this one as it was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this based on this comment: ros2/console_bridge_vendor#9 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was changed under the impression that older CMake versions had an issue otherwise. I would guess that was won't the problem was coming from somewhere else. So referring that change sounds reasonable.
I am okay with splitting this PR. I think I could do the following, which could hopefully be merged individually:
|
dbe8c2c
to
2b6f5d3
Compare
@@ -5,8 +5,9 @@ find_package(ament_cmake REQUIRED) | |||
|
|||
include(ExternalProject) | |||
# Single producer single consumer queue by moodycamel - header only, don't build, install | |||
ExternalProject_Add(singleproducerconsumer | |||
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/single | |||
ExternalProject_Add(ext-singleproducerconsumer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deliberately left in these changes because the cmake target of the ExternalProject_Add
would collide with add_library
.
I would ask for another round of review here. I hope I could strip down the packages well enough to make the changes easier to grasp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I will leave the actual approval to one of the maintainers.)
list(APPEND zstd_TARGETS zstd::zstd) | ||
else() | ||
message(FATAL_ERROR "Unable to find zstd") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this package doesn't use linters yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not and but can be added in a follow up PR.
ament_export_dependencies(pluginlib | ||
rosbag2_storage | ||
rosidl_runtime_c | ||
rosidl_runtime_cpp | ||
rosidl_typesupport_cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this related to the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding, when importing a cmake target, all dependencies have to present at cmake's generation step as opposed to using ${<pkg>_LIBRARIES}
which is applied during linking. It's therefore important to export all necessary dependencies.
endif() | ||
list(APPEND zstd_TARGETS zstd::zstd) | ||
else() | ||
message(FATAL_ERROR "Unable to find zstd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I usually try to exit early to avoid indentation, like:
if(NOT zstd_FOUND)
message(FATAL_ERROR "Unable to find zstd")
endif()
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exiting early is preferred.
There was actually another problem in here though, in that it would fail (FATAL_ERROR
) regardless whether find_package(zstd)
was called with REQUIRED
or not. So I've changed that. With this however, I don't see a good way of exiting earlier anymore.
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Knese Karsten <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
93465ab
to
03702f8
Compare
* wip export targets Signed-off-by: Karsten Knese <[email protected]> * correct include dirs Signed-off-by: Karsten Knese <[email protected]> * relative include paths for vendor packages Signed-off-by: Karsten Knese <[email protected]> * cleanup rosbag2_test_common Signed-off-by: Karsten Knese <[email protected]> * cleanup shared_queues_vendor package Signed-off-by: Karsten Knese <[email protected]> * cleanup sqlite3 vendor package Signed-off-by: Karsten Knese <[email protected]> * cleanup zstd_vendor package Signed-off-by: Karsten Knese <[email protected]> * cleanup rosbag2_compression Signed-off-by: Karsten Knese <[email protected]> * touchups for isolated build Signed-off-by: Knese Karsten <[email protected]> * export typesupport Signed-off-by: Karsten Knese <[email protected]> * organize included dependencies Signed-off-by: Karsten Knese <[email protected]> * unknown import target for sqlite3 Signed-off-by: Karsten Knese <[email protected]> * try debugging windows Signed-off-by: Karsten Knese <[email protected]> * remove fatal error warning Signed-off-by: Karsten Knese <[email protected]> * limit amount of change Signed-off-by: Karsten Knese <[email protected]> * use CMAKE_INSTALL_PREFIX Signed-off-by: Karsten Knese <[email protected]> * fatal_error only when required Signed-off-by: Karsten Knese <[email protected]> Signed-off-by: P. J. Reed <[email protected]>
Closes #402
Requires ros/pluginlib#190